package com.ganeshkrishnan.globald.dao.hibernate;

import java.util.List;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.ganeshkrishnan.globald.abstracts.GenericDaoHibernate;
import com.ganeshkrishnan.globald.dao.PersonDao;
import com.ganeshkrishnan.globald.model.Person;

@Repository("personDao")
@Transactional
public class PersonDaoHibernate extends GenericDaoHibernate<Person, Long> implements PersonDao {
	public PersonDaoHibernate() {
		super(Person.class);
	}

	public List<Person> findByLastName(String lastName) {
		return getHibernateTemplate().find("from Person where lastName=?", lastName);
	}

	@SuppressWarnings("unchecked")
	public List<Person> findByCountryCode(int countryCode) {
		return getHibernateTemplate().find("from Person where countryCode=?", countryCode);
	}

	public List<Person> findByKarma(int Karma) {
		return getHibernateTemplate().find("from Person where Karma=?", Karma);
	}

	public List<Person> findByKarmaRange(int karmaBegin, int karmaEnd) {
		return getHibernateTemplate().find("from Person where Karma> " + karmaBegin + " and Karma<" + karmaEnd);
	}

	public List<Person> findByLevel(int level) {
		return getHibernateTemplate().find("from Person where level=?", level);
	}

	public List<Person> findByPowerRange(int powerBegin, int powerEnd) {
		return getHibernateTemplate().find(
				"from Person where PowerLevel> " + powerBegin + " and PowerLevel<" + powerEnd);
	}

	public List<Person> getPersonList() {
		// TODO Auto-generated method stub
		return null;
	}

	public void savePerson(Person prod) {
		// TODO Auto-generated method stub

	}
}
